package com.mxpio.erp.common.jpa.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mxpio.erp.common.jpa.policy.BizCodeGeneratorPolicy;
import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 订单父类
 * @author MxpIO
 */
@Data
@MappedSuperclass
@EqualsAndHashCode(callSuper=false)
public abstract class Order extends BaseEntity {

	private static final long serialVersionUID = 1L;

	public Order(){
		super();
		this.setTypeCode(initTypeCode());
	}

	@Id
	@Column(name = "BIZ_NO_", updatable = false)
	@Generator(policy = BizCodeGeneratorPolicy.class)
	@Schema(description = "业务单号")
	private String bizNo;
	
	@Column(name = "BPMN_STATUS_")
	@Schema(description = "审核状态")
	@Dict(dicCode = "ERP_COMMON_BPMN_STATUS")
	private String bpmnStatus;
	
	@Column(name = "ORDER_STATUS_")
	@Schema(description = "执行状态")
	@Dict(dicCode = "ERP_COMMON_ORDER_STATUS")
	private String orderStatus;
	
	@Column(name = "CLOSE_STATUS_")
	@Schema(description = "关闭状态")
	@Dict(dicCode="ERP_COMMON_CLOSE_STATUS")
	private String closeStatus;

	@Column(name = "TYPE_CODE_", updatable = false)
	@Schema(description = "订单类型")
	private String typeCode;
	
	@Column(name = "ORDER_DATE_")
	@Schema(description = "单据日期")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date orderDate;
	
	@Column(name = "REVIEWER_")
	@Schema(description = "审核人")
	private String reviewer;

	@Column(name = "REVIEW_TIME_")
	@Schema(description = "审核时间")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date reviewTime;
	
	@Column(name = "EXECUTOR_")
	@Schema(description = "执行人")
	private String executor;
	
	@Column(name = "EXECUTE_TIME_")
	@Schema(description = "执行时间")
	@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
	private Date executeTime;

	public abstract String initTypeCode();
}
